package com.lichuang.dedao.user.vo;

import com.lichuang.dedao.user.entity.User;
import com.lichuang.dedao.user.enums.Education;
import com.lichuang.dedao.user.enums.Gender;
import com.lichuang.dedao.user.utils.BeanUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode
public class UserVO extends User {

    private String userGenderName;

    private String educationName;

    public static UserVO transferVo(User user) {

        UserVO userVO = BeanUtil.copy(user, UserVO.class);

        // 将性别枚举转换为字符串
        Gender gender = Gender.genderOf(userVO.getUserGender());
        if (gender != null) {
            userVO.setUserGenderName(gender.getName());
        }

        // 将学历枚举转换为字符串
        Education education = Education.EducationOf(userVO.getEducation());
        if (education != null) {
            userVO.setEducationName(education.getName());
        }

        return userVO;
    }
}
